<?php

use Phinx\Migration\AbstractMigration;

class ModifyMediaTableColumn extends AbstractMigration
{
    public function up()
    {
        $this->table("media")
            ->changeColumn("type", "char", [
                "limit" => 36,
                "comment" => "类型",
                "default" => "thumb",
                "null" => false
            ])
            ->addColumn("param", "json", [
                "default" => null,
                "comment" => "mediaData存储",
            ])->save();
    }

    public function down()
    {
        $this->table("media")
            ->changeColumn("type", "enum", [
                "values" => "thumb,attachment",
                "null" => false,
                "default" => "thumb",
            ])
            ->removeColumn("param")
            ->save();
    }
}
